package com.kingstar.ceres.mapper.master;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kingstar.ceres.entity.master.CfetsRmbCmdsMarketdataSendRecord;
import com.kingstar.ceres.mapper.base.BaseDao;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 *  Mapper 接口
 *
 * @author 
 * @since 2022-03-28
 */
@Repository
public interface CfetsRmbCmdsMarketdataSendRecordDao extends BaseMapper<CfetsRmbCmdsMarketdataSendRecord> , BaseDao {
    @Select({
            "<script>",
            "SELECT imixtext FROM cfets_cmds_standard_rate",
            "WHERE id>=(SELECT id FROM cfets_cmds_standard_rate",
            "WHERE 1=1",
            "<when test='beginDate!=null'>",
            "AND transactdatetime >= #{beginDate}",
            "</when>",
            "<when test='endDate!=null'>",
            "AND transactdatetime &lt; #{endDate}",
            "</when>",
            "ORDER BY id limit #{start},1",
            ") LIMIT #{size}",
            "</script>"
    })
    List<CfetsRmbCmdsMarketdataSendRecord> pageQuery(@Param("start") Integer start,
                                          @Param("size") Integer size,
                                          @Param("beginDate") Date beginDate,
                                          @Param("endDate") Date endDate);

    @Select({
            "<script>",
            "SELECT COUNT(1) FROM cfets_cmds_standard_rate",
            "WHERE 1=1",
            "<when test='beginDate!=null'>",
            "AND transactdatetime >= #{beginDate}",
            "</when>",
            "<when test='endDate!=null'>",
            "AND transactdatetime &lt; #{endDate}",
            "</when>",
            "</script>"
    })
    Integer count(@Param("beginDate") Date beginDate,
                  @Param("endDate") Date endDate);
}
